<%@ page language="java" import="com.alibaba.fastjson.JSONObject" pageEncoding="UTF-8" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.hrm.company.DepartmentComInfo" %>
<%@ page import="weaver.hrm.resource.ResourceComInfo" %>
<%@ page import="com.alibaba.fastjson.JSONArray" %>
<%--获取流水号--%>
<%
    JSONArray jsonArray = new JSONArray();
    RecordSet rs = new RecordSet();
    rs.executeQuery( "select top 4 xh,ycmc,zrbm,hbry,lxry,yjsc from uf_hydp where dqzt !=1");
    while (rs.next()){
        JSONObject jsonData = new JSONObject();
        String zrbm = Util.null2String(rs.getString( "zrbm" ));
        String hbry = Util.null2String(rs.getString( "hbry" ));
        String lxry = Util.null2String(rs.getString( "lxry" ));
        jsonData.put("hrmmembers",getUserName(lxry));
        jsonData.put("reportmembers",getUserName(hbry));
        jsonData.put("depart",getDepartName(zrbm));
        jsonArray.add(jsonData);
        out.print("jsonData="+jsonData.toJSONString());
    }
    out.print(jsonArray.toJSONString());
%>
<%!
    public static String getUserName(String ids) {
        String lastnames = "";
        try {
            String[] strs = ids.split( "," );
            ResourceComInfo hrmComInfo = new ResourceComInfo();
            for (String id : strs) {
                String lastname = hrmComInfo.getLastname( id );
                lastnames += "".equals( lastnames ) ? lastname : "," + lastname;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return lastnames;
    }

    public static String getDepartName(String ids) {
        String departnames = "";
        try {
            DepartmentComInfo depComInfo = new DepartmentComInfo();
            String[] strs = ids.split( "," );
            for (String id : strs) {
                String departname = depComInfo.getDepartmentName( id );
                departnames += "".equals( departnames ) ? departname : "," + departname;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return departnames;
    }
%>